package cn.hsw.platform.core.validated.valid;

import cn.hsw.platform.core.util.Validator;
import cn.hsw.platform.core.validated.annotations.Phone;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * 手机号校验
 * @author 李子木
 * @date 2020-11-02
 */
public class PhoneValid implements ConstraintValidator<Phone,String> {
    @Override
    public void initialize(Phone constraintAnnotation) {

    }

    @Override
    public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {

        if(!Validator.isEmpty(s)) {
            return Validator.isMobile(s);
        }else{
            return false;
        }
    }
}
